Integrate Algolia into the storefront sample app
Connect Algolia to your headless Salesforce B2C Commerce using the official sample app.
This guide describes how to connect Algolia to a headless Salesforce B2C Commerce storefront with the storefront sample app.
Salesforce deprecated the sample app and recommends using the Progressive Web App (PWA) Kit.
To set up Algolia for your headless Salesforce B2C Commerce storefront, see Headless commerce.
Download and run the SFCC storefront sample app
-
Clone the sample app GitHub repository:
sh -
Follow the setup instructions to create a frontend with the native search.
Download and compile Unified InstantSearch
-
Clone the Unified InstantSearch GitHub repository into the
packages/
directory. -
Delete the
unified-instantsearch-ecommerce/.git
directory from theunified-instantsearch-ecommerce
directory.sh -
Install the dependencies and compile.
sh
This creates a new folder unified-instantsearch-ecommerce/export
which contains the assets you need for a working search in the sample app.
Import Unified InstantSearch into the sample app
-
Add the Unified UI assets to be copied into the
storefront-lwc
package. Edit the filepackages/storefront-lwc/scripts/plugin-copy-assets.js
:jsNow, building
storefront-lwc
automatically imports Unified UI files. -
Include the new files in the
index.html
file:html -
Create a new Lightning Element that serves as a host for the Algolia Unified UI. In the directory
packages/storefront-lwc/src/modules/
, create the following files:sh
Add the following code to the files algoliaUnifiedUi.html
and algoliaUnifiedUi.js
:
Click and conversion events
To complete your setup, send click and conversion events.